<?php
namespace App\Model;

class Shop extends Model
{
    // 表名
    protected $table = 'shops';
    
    // 保护属性
    protected $guarded = [];
    
    protected $attributes = [
        'shop_id'=> 0,
        'status' => self::STATUS_NO,
        'last_time'  => 0,
        'check_time' => 0,
        'status_time'=> 0
    ];
    
    protected $dateFormat = 'U';
    
    const STATUS_OK = 1;
    const STATUS_NO = 0;
    
    // 用户
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
    
    // 上级店铺
    public function shop()
    {
        return $this->belongsTo(Shop::class, 'shop_id');
    }
    
    // 充值
    public function userPay()
    {
        return $this->hasMany(UserPay::class, 'shop_id');
    }
}